import { StatisticAPI } from "@/api";
import FormInput from "@/components/Input";
import Load from "@/components/Loading";
import { AppContext } from "@/context";
import {
  ArrayList,
  curry,
  fibonacci,
  fibonacci2,
  getParams,
  LazyMan,
} from "@/utils";
import { useFetch } from "@/utils/hooks";

import { useIDefinedProperty } from "@/utils/Proxy";

import classNames from "classnames";
import React from "react";

import { useCallback, useContext, useEffect, useRef, useState } from "react";
import styles from "./index.module.less";

const str = "YYYY-MM-DD";

const reg = /^[1-9]{4}-([1]{1}[012]{1}|[0]?[1-9]{1})-()$/;

const Statistics = () => {
  const classNmae = classNames();
  const [data, getData, loading] = useFetch(StatisticAPI.fetchStatistic);

  // console.log(import.meta.env);
  // console.log(data);

  const { data: data2 } = useContext(AppContext);
  // console.log(data2);

  // useEffect(() => {
  //   getData({
  //     type: "total",
  //     range: "self",
  //   });
  // }, []);

  const [value, setValue] = useState("");

  const fatherHandle = useCallback(() => {
    console.log("father");
  }, []);

  const ref = useRef<number | undefined>(undefined);

  // useEffect(() => {
  //   if (value) {
  //     // ref.current = setTimeout(() => {
  //     //   color = "skyblue";
  //     //   console.log("skye");
  //     //   clearTimeout(ref?.current);
  //     // }, 1000);
  //   }

  //   return () => {
  //     clearTimeout(ref?.current);
  //   };
  // }, [value]);

  // const iObject = IProxy({});
  // iObject.name = 1234;
  // iObject.age = "18";
  // iObject.name;
  // console.log("isobj", iObject.name);

  const obj = useIDefinedProperty();

  // console.info(rotatle([1, 2, 3, 4, 5, 6, 7], 3));

  // const I = new IPromise((resolve) => {
  //   resolve("123");
  // });
  // console.info(I);

  // const person = new Person("112313", "123", "3213");
  // console.log(person);
  // person.age = "123";
  // console.info(Person.prototype);

  // console.log(sendMsg("1231"));
  // console.log(sendMsg(1));

  const list = new ArrayList([
    { id: 1, name: "zs" },
    { id: 2, name: "lisi" },
  ]);

  // const area = new Area(1, 2);
  // console.log(area.getArea());

  // const area1 = new Area({ height: 1, width: 2 });
  // console.log(area1.getArea());

  // const obj1 = MyLocal.getInstance();
  // obj1.setItem("k", ["123123"]);
  // console.log(obj1.getItem("k"));

  // console.log(getParams({ key: "key" }));

  type Include<T, U> = T extends U ? T : never;
  type Exclude<T, U> = T extends U ? never : T;

  type DD = Exclude<'name'|'age','age'| 'key'>

  type PickSelf<T, U extends keyof T> = {
    [P in U]: T[P];
  };
  type A = PickSelf<{ name: string; age: string }, "age">;

  type OmitSelf<T, U extends keyof T> = {
    [P in Exclude<keyof T, U>]: T[P]
  }
  type B = OmitSelf<{ name: string; age: string }, "age">;

  return (
    <div>
      {/* <Load /> */}
      <FormInput
        placeholder="输入密码"
        value={value}
        onChange={(val) => {
          setValue(val);
        }}
      />
      <div>
        <div
          style={{
            width: 0,
            height: 0,
            borderTop: "30px solid transparent",
            borderLeft: "30px solid skyblue",
            borderBottom: "30px solid transparent",
            borderRight: "30px solid transparent",
          }}
        />
      </div>
    </div>
  );
};

export default Statistics;
